package com.tl.web.controller.app;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tl.common.annotation.Log;
import com.tl.common.core.controller.BaseController;
import com.tl.common.core.domain.AjaxResult;
import com.tl.common.enums.BusinessType;
import com.tl.app.domain.AppGiftUser;
import com.tl.app.service.IAppGiftUserService;
import com.tl.common.utils.poi.ExcelUtil;
import com.tl.common.core.page.TableDataInfo;

/**
 * 打赏礼物Controller
 * 
 * @author suhp
 * @date 2024-07-28
 */
@RestController
@RequestMapping("/app/giftUser")
public class AppGiftUserController extends BaseController
{
    @Autowired
    private IAppGiftUserService appGiftUserService;

    /**
     * 查询打赏礼物列表
     */
    @PreAuthorize("@ss.hasPermi('app:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppGiftUser appGiftUser)
    {
        startPage();
        List<AppGiftUser> list = appGiftUserService.selectAppGiftUserList(appGiftUser);
        return getDataTable(list);
    }

    /**
     * 导出打赏礼物列表
     */
    @PreAuthorize("@ss.hasPermi('app:user:export')")
    @Log(title = "打赏礼物", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppGiftUser appGiftUser)
    {
        List<AppGiftUser> list = appGiftUserService.selectAppGiftUserList(appGiftUser);
        ExcelUtil<AppGiftUser> util = new ExcelUtil<AppGiftUser>(AppGiftUser.class);
        util.exportExcel(response, list, "打赏礼物数据");
    }

    /**
     * 获取打赏礼物详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:user:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appGiftUserService.selectAppGiftUserById(id));
    }

    /**
     * 新增打赏礼物
     */
    @PreAuthorize("@ss.hasPermi('app:user:add')")
    @Log(title = "打赏礼物", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppGiftUser appGiftUser)
    {
        return toAjax(appGiftUserService.insertAppGiftUser(appGiftUser));
    }

    /**
     * 修改打赏礼物
     */
    @PreAuthorize("@ss.hasPermi('app:user:edit')")
    @Log(title = "打赏礼物", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppGiftUser appGiftUser)
    {
        return toAjax(appGiftUserService.updateAppGiftUser(appGiftUser));
    }

    /**
     * 删除打赏礼物
     */
    @PreAuthorize("@ss.hasPermi('app:user:remove')")
    @Log(title = "打赏礼物", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appGiftUserService.deleteAppGiftUserByIds(ids));
    }
}
